# compiler flags 
LANG = C
LINK_OPENMP_ICC = -openmp
LINK_MKL_ICC = -L/opt/intel/Compiler/11.1/059/mkl/lib/em64t/ \
			   -Wl,-R/opt/intel/Compiler/11.1/059/mkl/lib/em64t/ \
			   -lmkl_lapack -lmkl_intel_lp64 -lmkl_intel_thread \
			   -lmkl_core -liomp5 -lpthread -lm
#CC = gcc
CC = icc
CFLAGS = -O3 -lm -lrt -msse4 $(LINK_MKL_ICC) $(LINK_OPENMP_ICC)

# object files
%.o : %.c
	$(CC) -c $< $(CFLAGS)

# define targets, common objects/headers, and object files
TARGETS =
TARGETS += benchmark--outer
TARGETS += benchmark--outer_two
TARGETS += benchmark--all
COMMON_OBJS = benchmark.o stopwatch.o matrix_utils.o
COMMON_HEADERS = stopwatch.h matrix_utils.h matmult.h
OUTER_MM = matmult_outer.o
OUTER_TWO_MM = matmult_outer_two.o
ALL_MM = matmult_all.o
all: $(TARGETS)

# compilation
benchmark--outer : $(COMMON_OBJS) $(OUTER_MM)
	$(CC) -o $@ $^ $(CFLAGS)
benchmark--outer_two : $(COMMON_OBJS) $(OUTER_TWO_MM)
	$(CC) -o $@ $^ $(CFLAGS)
benchmark--all : $(COMMON_OBJS) $(ALL_MM)
	$(CC) -o $@ $^ $(CFLAGS)

# clean
.PHONY : clean
clean : 
	rm -f $(TARGETS)
	rm -f *.o
	
